package edu.sctu.practice.class02.yangyuran.test18;

import java.util.Scanner;

/**
 * Created by Administrator on 2015/10/12.
 */
public class Auto {

    public int tires;
    public String color;
    public String brand;
    public int weight;
    public int speed;


    public Auto() {

        this.tires = 4;
        this.weight = 10;
        this.speed = 80;
    }


    public Auto(String color, String brand) {
        this.color = "蓝色";
        this.brand = "奔驰";
    }


    public void addSpeed(int speed) {
        System.out.println("初始速度为：" + this.speed);
        System.out.println("请输入要增加的速度（请不要超出正常速度）：");
        Scanner scan = new Scanner(System.in);
        int spee = scan.nextInt();
        int newspeed = this.speed + spee;
        System.out.println("增加后的速度为：" + newspeed);
    }


    public void cutSpeed(int speed) {
        System.out.println("初始速度为：" + this.speed);
        System.out.println("请输入要减少的速度（请不要使得速度小于零）：");
        Scanner scan = new Scanner(System.in);
        int spe = scan.nextInt();
        int newspeed01 = this.speed - spe;
        if (newspeed01 >= 0) {
            System.out.println("减少后的速度为：" + newspeed01);
        } else {
            System.out.println("汽车停车了。");
        }
    }
}
